# -*- coding: utf-8 -*-
"""
Module Description:日志类，封装了写日志需要的参数
Date: 2017/7/29
Anchor:wf
"""
from pyshare.const.enums.log import FieldName


class LogParam(object):
    """
    日志类
    field_name：资源日志分类
    old_val：旧值
    new_val：新值
    scene：接口号、扩展为查询条件（如道具：item_type:item_id）
    remark：备注
    reserve：扩展字段（供展示用，不作为查询条件）
    """
    def __init__(self, rid, field_name=FieldName.Item, old_val=0, new_val=0, scene='Unknown', remark='', reserve=None,
                 server_id=None):
        if reserve is None:
            reserve = {}
        self.rid = rid
        self.field_name = field_name
        self.old_val = old_val
        self.new_val = new_val
        self.scene = scene
        self.remark = remark
        self.reserve = reserve
        self.server_id = server_id


class LogEventParam(object):
    """
    事件日志类
    remark:备注
    role_id:
    event_code: 系统ID-子系统ID-事件ID（操作ID）
    event_data: 事件信息
    reserve:
    """
    def __init__(self, rid, event_code, event_data, remark='', reserve=None):
        if reserve is None:
            reserve = {}
        self.rid = rid
        self.event_code = event_code
        self.event_data = event_data
        self.remark = remark
        self.reserve = reserve


class LogRankParam(object):
    """
    排行榜日志类
    remark:备注
    event_code: 系统ID-子系统ID-事件ID（操作ID）
    rank_data: 排行榜信息
    reserve:
    """
    def __init__(self, event_code, rank_data, remark='', reserve=None):
        if reserve is None:
            reserve = {}
        self.event_code = event_code
        self.rank_data = rank_data
        self.remark = remark
        self.reserve = reserve


class LogRoleParam(object):
    """
    角色属性日志类
    pre_val：旧值
    cur_val：新值
    property_id：属性ID
    reserve：扩展字段（供展示用，不作为查询条件）
    """
    def __init__(self, rid, property_id, pre_val=0, cur_val=0, reserve=None, server_id=None):
        if reserve is None:
            reserve = {}
        self.rid = rid
        self.pre_val = pre_val
        self.cur_val = cur_val
        self.property_id = property_id
        self.reserve = reserve
        self.server_id = server_id
